import 'package:flutter_taotaoshipin/app/app_controller.dart';
import 'package:flutter_taotaoshipin/util/other_utils.dart';
import 'package:flutter_taotaoshipin/value/constant.dart';
import 'package:get/get.dart';
import 'package:hi_net/request/hi_base_request.dart';

abstract class BaseRequest extends HiBaseRequest {
  @override
  String authority() {
    return 'apittsp.49wan.com';
  }

  @override
  get topPath => 'ios';

  @override
  get pathParams => 'dj';

  @override
  bool get useHttps => true;

  @override
  String url() {
    var appController = Get.find<AppController>();
    // 添加渠道id
    add('chn_id', appController.appProfile.chnId!);
    // 添加推广号
    add('ver', appController.appProfile.ver!);
    // 添加苹果密钥版本（新包不要了）
    // add('secret_version', 2);
    if (needLogin()) {
      // 添加登录令牌
      addHeaders('Session-Id', appController.localUserInfo.sessionId ?? '');
      // 添加用户id
      add('mid', appController.localUserInfo.mId ?? '');
    }
    return super.url();
  }
}
